#include <iostream>
#include <vector>
#include <algorithm>


using std::cin;
using std::cout;
using std::vector;

class AbstractDoer {
public:
    virtual void entering(int vertex) {};
    virtual void leaving(int vertex) {};
    virtual void if_used(int from, int to) {}
    virtual void before_iteration(int from, int to) {}
    virtual void after_iteration(int from, int to) {}
};

class TopSort : public AbstractDoer {
public:
    vector<int> order;
    bool has_cycle;

    TopSort() {
        order.clear();
        has_cycle = false;
    }

    void if_used(int vertex, int next_vertex) {
        has_cycle = true;
    }

    void leaving(int vertex) {
        order.push_back(vertex);
    }
};


void dfs(const vector<vector<int>>& graph, vector <int>& was, AbstractDoer* Doer, int vertex, int parent = -1) {
    was[vertex] = 1;
    Doer->entering(vertex);
    for (auto next_vertex : graph[vertex]) {
        if (next_vertex == parent)
            continue;
        if (was[next_vertex] == 1)  
            Doer->if_used(vertex, next_vertex);
        else {
            Doer->before_iteration(vertex, next_vertex);
            dfs(graph, was, Doer, next_vertex, vertex);
            Doer->after_iteration(vertex, next_vertex);
        }
    }
    Doer->leaving(vertex);
    was[vertex] = 2;
}


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    vector <vector <int> > e(n * 2 + 1);
    vector <int> was(2 * n + 1, 0);
    for (int i = 0; i < a; ++i) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        e[l * 2 + 1].push_back(r * 2);
    }
    for (int i = 0; i < b; ++ i) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        e[r * 2].push_back(l * 2 + 1);
        e[l * 2].push_back(r * 2 + 1);        
    }
    for (int i = 0; i < n; ++i) {
        e[i * 2].push_back(i * 2 + 1);
    }
    auto topsort = new TopSort();
    for (int i = 0; i < 2 * n; ++i) {
        if (!was[i]) {
            dfs(e, was, topsort, i);
        }
    }
    std::reverse(topsort->order.begin(), topsort->order.end());
    vector<int> xcoords(2 * n);
    for (int i = 0; i < topsort->order.size(); ++ i) {
        xcoords[topsort->order[i]] = i;
    }
    if (topsort->has_cycle) 
        cout << "Impossible";
    else {
        for (int i = 0; i < 2 * n; i+=2) {
            cout << xcoords[i] << " " << xcoords[i + 1] << std::endl;
        }
    }
}


